#-*- coding:UTF-8 -*-
# utils  实用工具

from django.http import HttpResponse
from rest_framework.renderers import JSONRenderer

class JSONHttpResponse(HttpResponse):
    """
    An HttpResponse that renders its content into JSON.
    """
    def __init__(self, data, **kwargs):
        json_data = JSONRenderer().render(data)
        content = json_data
        kwargs['content_type'] = 'application/json'
       
        parent = super(JSONHttpResponse, self)
        parent.__init__(content, **kwargs)
        parent.__setitem__("Access-Control-Allow-Origin", "*")
        pass
    pass